package TestMethod;

import java.util.Scanner;

//数组作为方法参数
public class MethodDemo5 {
    //打印输出一维数组元素的值的方法
    public void printArray(int[] arr){
        int count=0;
        System.out.println("该数组的元素为:");
        for (int n:arr) {
            System.out.print(n+" ");
            if (count==5){
                System.out.println();
                count=0;
            }
        }
        System.out.println();
    }
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你的数组长度:");
        int n=scanner.nextInt();
        int[] arr=new int[n];
        System.out.println("请输入你的"+n+"个整型数组元素:");
        for (int i=0;i<arr.length;i++){
            int a=scanner.nextInt();
            arr[i]=a;
        }
        MethodDemo5 methodDemo5=new MethodDemo5();
        methodDemo5.printArray(arr);
        methodDemo5.printArray(arr);

    }
}
